Documentation > CMS Template API Library > Asset > DeleteContentFields(List[String])

DeleteContentFields

Delete all the content fields whose names are in the given list.

public Dictionary<String,String> DeleteContentFields(List[String])


Returns

A Dictionary containing the old values of the removed fields

Parameters

NameDescriptionType
fieldsToRemove List of names of the fields to remove. List<String>

Code Example

C#

Sample:
Asset myAsset = Asset.Load("/_CPTest/Test");
if(myAsset.IsLoaded)
{
  List<string> fieldsToRemove = new List<string>();
  fieldsToRemove.Add("test");
  fieldsToRemove.Add("panel:3");
  fieldsToRemove.Add("field:3");

  Dictionary<string, string> removedFields = myAsset.DeleteContentFields(fieldsToRemove);
  if(removedFields.Count > 0)
  {
    foreach(KeyValuePair<string, string> kvp in removedFields)
    {
      Out.WriteLine("Key: " + kvp.Key + "<br />");
      Out.WriteLine("Value: " + kvp.Value + "<br />");
    }
  }
}

Connect with Crownpeak